package com.sxit.tdf.server.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author 胡乖乖童鞋
 * @date 2022/3/26 9:53
 * @describe
 */
@Component
public class EmailSendUtil {

  @Autowired private JavaMailSender javaMailSender;

  @Async
  public void SendMsg(String msg, String toMsg, String subject) {

    SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
    simpleMailMessage.setText(msg);
    simpleMailMessage.setSubject("教学资料管理系统通知信息-" + subject);

    simpleMailMessage.setFrom("");
    simpleMailMessage.setTo(toMsg);
    simpleMailMessage.setCc("");
    System.out.println("------->" + toMsg);
    try {
      javaMailSender.send(simpleMailMessage);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
